{The unit TitrHelp provides a crude (non-contextual) Help system by displaying }
{separate ASCII text files in a memo.  The user selects topics via a drop-down }
{list.  The Help files should be placed in the same directory as the }
{executable file.}

unit TitrHelp;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, TitrDefs;

type
  TTitrHelpForm = class(TForm)
    HelpMemo: TMemo;
    HelpTopicBox: TComboBox;
    Label1: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure HelpTopicBoxExit(Sender: TObject);
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  TitrHelpForm: TTitrHelpForm;

implementation

{$R *.dfm}

{When the form is created, the list of help topics is read into the drop-down}
{combo box control, and the general help file is displayed in the memo }

procedure TTitrHelpForm.FormCreate(Sender: TObject);

 Var   i : integer;                            {topic counter}

begin
   HelpTopicBox.Items.Clear;                   {Clearing is probably unnecessary}
   For i := 1 to NumHelp do                    {now read in all the help topics}
       HelpTopicBox.Items.add(HelpTopics[i]);
   HelpTopicBox.ItemIndex := 0;                {set the combobox index}
   HelpIndex := 1;
   HelpMemo.Lines.LoadFromFile(HelpDir + HelpFiles[1] + '.hlp'); {and show the general help}
end;

{When the user changes topics or exits the drop-down list, the selected }
{ASCII file is displayed}

procedure TTitrHelpForm.HelpTopicBoxExit(Sender: TObject);
begin
   HelpIndex := HelpTopicBox.ItemIndex + 1;
   HelpMemo.Lines.LoadFromFile(HelpDir + HelpFiles[HelpIndex] +'.hlp');
end;

{When the form is invoked from the main program, the topic corresponding to }
{HelpIndex is displayed.  This allows the program to provide some guidance }
{in the initial choice of help topic}

procedure TTitrHelpForm.FormActivate(Sender: TObject);
begin
   HelpTopicBox.ItemIndex := HelpIndex -1;
   HelpMemo.Lines.LoadFromFile(HelpDir + HelpFiles[HelpIndex] +'.hlp');
end;

end.
